<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Home\Controller;

use Common\Api\BookGameApi;
/*
 * 	统计分析
 *   */
class AnalysisController extends HomeController {
	/*
	 * 	查看当前学生的学生比赛信息
	 *   
	 *   */
	public function index(){
		$student  =  D('Student');
		$rst      =  $student->searchBookGame(array(0,2),1,session('user_auth.uid'));
		$this->assign('bookgame',$rst);
		$this->display();
	}
	
	public function analysis(){
		$bookGameId   = I('get.bookgameid');
		$bookGameName = I('get.bookgamename');
		$studentId  = session('user_auth.uid');
		$classId    = session('user_auth.classid');
		$bookApi    = new BookGameApi();
		$readTimes  = $bookApi->getReadTimeByGameIdAndStudentId($bookGameId, $studentId);
		$score      = $bookApi->getScoreByClassId($bookGameId,$classId,10);
// 		dump($readTimes);
// 		dump($score);
		foreach ($score as $key=>$val){
			$integral[$key]  =$val['integral'];
		}
		array_multisort($integral,SORT_ASC,$score); 
		$this->assign('bookgamename',$bookGameName);
		$this->assign('score',$score);
		$this->assign('readtimes',$readTimes);
		
		$this->display();
	
	}
	
}
